GET_CHAT_OBJ=false;//GET_CHAT_OBJ是一个全局的消息获取对象
String.prototype.len=function(){//计算string长度 汉字为2
	return this.replace(/[^\x00-\xff]/g,"aa").length;
}
function makeChatWindow(chatTo){
	ajax.get('checkchatuser.php?action=checkuser&chatto='+chatTo,checkReChat);
}
function checkReChat(restr){
	var re=parseJson(restr);
	if(1!=re.result)	return;
	var chatObj=new bluebirdChat(re['chatto'],re['chatToUser']);
	chatObj.init();
	if(false==GET_CHAT_OBJ)	GET_CHAT_OBJ=new getChat();
	if(0==GET_CHAT_OBJ.chatObj.length){ //如果chatObj对象为空 有两种情况:1.第一次初始化 2.已经初使化,但是所有chatObj已经关闭
		GET_CHAT_OBJ.goOn=true;
		GET_CHAT_OBJ.init();
	}
	GET_CHAT_OBJ.chatObj.push(chatObj);
}
function bluebirdChat(chatTo,chatToUser){
	this.chatTo=chatTo;//和谁(id)聊天
	this.chatToUser=chatToUser;//和谁(显示名称)聊天
}
bluebirdChat.prototype={
	sMethod:1,//发送方式 1:ctrol+enter 0:enter
	sMethodDiv:false,//选择发送方式的面板状态,false:还未生成..
	fontDiv:false,
	errDiv:false,//显示错误的面板
	isList:false,//是否有展开的list
	currentList:null,//当前展开的list
	userStyle:{},//用户使用的聊天样式
	sendTime:0,//上次发送消息的时间 不能频率发送
	listLen:0,//显示的聊天记录条数
	init:function(){
		//if(this.getChatCookie()!=null)	return alert('系统检测到您已经开了一个聊天窗口。\n提示：您可能打开了多个本网站的页面，并在其中的某个页面打开了聊天窗口。');
		this.setChatCookie(true);//开始聊天,一个用户不能开几个窗口一起聊天
		this.lists=[];
		var sendBtn=makeButton('发  送');
		var closeBtn=makeButton('关  闭');
		var sendMethod=$C('input',{'type':'button','class':'mini_btn','value':'↓'});
		eve.observe(sendMethod,'click',this.showSendMethod,this);
		switchEffect(sendMethod,'mini_btn_over');
		eve.observe(sendBtn,'click',this.sendMsg,this);
		//var content=$C('iframe',{'class':'content'});
		this.content=$C('textarea',{'class':'content'});
		//content.frameBorder=0;
		this.lists.push(new setStyle(this));
		var font=this.lists[0].init();
		this.lists.push(new addEmote(this));
		var emote=this.lists[1].init();
		this.lists.push(new useShort(this));
		var phrase=this.lists[2].init();
		this.lists.push(new showHelp(this));
		var help=this.lists[3].init();
		this.msgList=$C('div',{'class':'msglist'});
		this.chatWindow=$C('div',{},
						$C('div',{'class':'chatbar'},'与'+this.chatToUser+'聊天'),
						$C('div',{'class':'message'},
							$C('div',{'class':'dark'},
								$C('img',{'src':'images/chat/dark_c.gif'})
							),
							this.msgList
						),
						$C('div',{'class':'iconbar'},font,emote,phrase,help),$C('div',{'class':'clear'}),
						$C('div',{'class':'editor'},
							$C('div',{'class':'dark'},
								$C('img',{'src':'images/chat/dark_c.gif'})
							),
							$C('div',{'class':'typediv'},this.content)
						),
						$C('div',{'class':'sendDiv'},closeBtn,sendBtn,sendMethod)
					);
		//bluebirdWindow.prototype.closeWindow=this.closeChat;//重构bluebirdWindow的关闭事件
		this.frame=bluebirdDialog.html(this.chatWindow,'在线咨询客服',370,'chatwindow',true);//this.frame是bluebirdWindow对象
		eve.observe(closeBtn,'click',this.frame.closeWindow,this.frame);
		eve.observe(closeBtn,'click',this.closeChat,this);
		eve.observe(this.frame.closeImg,'click',this.closeChat,this);
		eve.observe(window,'unload',this.closeChat,this);
		//this.frame.chatObj=this;//再把bluebirdChat对象给bluebirdWindow对象的chatObj属性. 这么做是为了关闭窗口的时候对执行bluebirdChat对象的关闭事件.
		//frame.prototype.;
		//this.editframe=content.contentWindow;
		//this.editframe.document.open();
		//this.editframe.document.write('<html><head><style type="text/css">body{background:#fff;margin:0px;padding:5px;font-size:13px;word-wrap:break-word;}p{margin:0;line-height:18px;}</style></head><body>你好</body></html>');
		//this.editframe.document.close();
		//this.editframe.document.designMode='on';
		//setTimeout(function(){
		eve.observe(document,'click',this.closeList,this);
		eve.observe(this.content,'keydown',this.checkKeyCode,this);
		//this.req=new getChat('chat.php?chatto='+chatto,this.displayMsg);
		//this.req.init();
//			eve.observe(this.editframe.document,'click',this.closeList,this);
//			eve.observe(this.editframe.document,'keydown',this.checkKeyCode,this);
//			eve.observe(this.editframe.document.body,'paste',function(){alert('paste');});
		//}.bind(this),500);

	},
	sendMsg:function(){
		var content=this.content.value;
		content=encodeHtml(content);
		var utc=Date.parse(new Date)/1000;
		if(utc-this.sendTime<2)	return this.showErr('请不要频率发送消息');
		if(''==content)	return this.showErr('发送内容不能为空');
		this.sendTime=utc;
		var obj={'c':content};
		for(var s in this.userStyle){//这样的话,不用判断是否有样式
			obj['s']=this.userStyle;
			break;
		}
		//alert(postParam(obj));
		var dataStr=postParam(obj);
		if(dataStr>950)	return this.showErr('报歉，聊天内容不能太长。');
		ajax.post('postchat.php?chatto='+this.chatTo,dataStr,this.sendResult.bind(this));
		this.appendChat(obj,'me',0,utc);//obj是聊天信息的json对象,'me'是CSS '0'是自己发的信息,utc是时间串
		this.content.value='';
		this.content.focus();
	},
	getEmote:function(str){
		var tmpEmote;
		while(/<span contenteditable=false><img[^s]*src=\"([^>]+)\"[^s]*><\/span>/i.test(str)){
			tmpEmote=RegExp.$1;
			tmpEmote=tmpEmote.split('/');
			tmpEmote=tmpEmote[tmpEmote.length-1];
			tmpEmote='[emote='+tmpEmote+']';
			str=str.replace(/<span contenteditable=false><img[^s]*src=\"[^>]+\"[^s]*><\/span>/i,tmpEmote);
		}
		return str;
	},
	appendChat:function(chatObj,whocss,who,utc){
		var content=decodeHtml(chatObj.c);
		var msgDiv=$C('div',{'class':'cont'},content);
		if(chatObj.s){
			for(var s in chatObj.s){
				msgDiv.style[s]=chatObj['s'][s];
			}
		}
		if(this.listLen++>50){//如果聊天记录数已经超过50条，删除第一条
			var fChild=this.msgList.firstChild;
			this.msgList.removeChild(fChild);
			fChild=null;
		}
		var whoName=(0==who)?' 我 ':this.chatToUser+' ';
		var date=new Date(utc*1000);//转换成毫秒
		var timeStr=(date.getYear()+((browser.ie)?0:1900))+'-'+date.getMonth()+'-'+date.getDate()+' '+date.getHours()+':'+date.getMinutes()+':'+date.getSeconds();
		this.msgList.appendChild($C('div',{},$C('div',{'class':whocss},whoName,timeStr),msgDiv));
		this.msgList.scrollTop=this.msgList.scrollHeight-this.msgList.offsetHeight;
	},
	sendResult:function(re){
		//todo..
	},
	showErr:function(esg){
		if(false==this.errDiv){
			var errDiv=$C('div',{'class':'chat_note hide'});
			document.body.appendChild(errDiv);
			this.errDiv=errDiv;
		}
		removeClass(this.errDiv,'hide');
		this.errDiv.innerHTML=esg;
		p=getPosition(this.content);
		this.errDiv.style.zIndex=bluebirdWindow.prototype.zindex;
		this.errDiv.style.left=p[1]+'px';
		this.errDiv.style.top=p[0]+'px';
		if(false==this.isList||this.currentList!=this.errDiv)	setTimeout(function(){this.isList=true;this.currentList=this.errDiv}.bind(this),200);
	},
	setChatCookie:function(isChat){//设置聊天状态的cookie
		bluebirdhszCookie.set('bluebirdChat',(isChat)?window.location.href:null,{secure:true});//写cookie,记录用户正开始聊天
	},
	getChatCookie:function(){
		return bluebirdhszCookie.get('bluebirdChat');
	},
	displayMsg:function(){},
	closeChat:function(){
		this.setChatCookie(false);//结果聊天cookie
		eve.stopObserve(document,'click',this.closeList);
		eve.stopObserve(this.content,'keydown',this.checkKeyCode);
		eve.stopObserve(window,'unload',this.closeChat);
		for(var i=this.lists.length-1;i>=0;i--){
			this.lists[i].die();
			this.lists[i]=null;
		}
		//GET_CHAT_OBJ.removeObj(this);
		this.lists=null;
	//	alert(this.sMethod);
	},
	closeList:function(){//关闭下拉选项
		//debug(this.isList);
		if(false==this.isList)	return;
		addClass(this.currentList,'hide');
		this.isList=false;
	},
	checkKeyCode:function(e){
		var k=e.keyCode||e.which;
		if(13!=k)	return;
		if((1==this.sMethod&&e.ctrlKey)||(0==this.sMethod&&!e.ctrlKey)){
			this.sendMsg();
			return false;
		}else if(e.ctrlKey&&0==this.sMethod){
			this.enter();
		}
	},
	enter:function(){//当发送方式为0,按下Ctrl+enter键时回车效果.
		if(browser.ie){
			document.selection.createRange().duplicate().text='\r';//加入换行符 
		}else{
			var cursorStart=this.content.selectionStart;//光标开始
			var cursorEnd=this.content.selectionEnd;//光标结束
			var tmpValue=this.content.value;
			this.content.value=tmpValue.substr(0,cursorStart)+'\n'+tmpValue.substr(cursorEnd);//加入换行符 
			this.content.selectionEnd=this.content.selectionStart=cursorStart+1;//重置光标的位置
		}
	},
	showSendMethod:function(e){
		var btn=e.srcElement||e.target;
		var p=getPosition(btn);
		if(false==this.sMethodDiv)	this.sMethodDiv=this.createSendMethodDiv();
		removeClass(this.sMethodDiv,'hide');
		this.sMethodDiv.style.zIndex=bluebirdWindow.prototype.zindex;
		this.sMethodDiv.style.left=p[1]+20+'px';
		this.sMethodDiv.style.top=p[0]+'px';
		if(false==this.isList||this.currentList!=this.sMethodDiv)	setTimeout(function(){this.isList=true;this.currentList=this.sMethodDiv;}.bind(this),200);
	},
	createSendMethodDiv:function(){
		var method_1=$C('div',{'class':'item'+((0==this.sMethod)?' item_sele':'')},'按Enter键发送消息');
		method_1.unselectable=true;
		var method_2=$C('div',{'class':'item'+((1==this.sMethod)?' item_sele':'')},'按Ctrl+Enter键发送消息');
		switchEffect(method_1,'item_over');
		switchEffect(method_2,'item_over');
		method_1.val=0;
		method_2.val=1;
		eve.observe(method_1,'click',this.setSendMethod,this);
		eve.observe(method_2,'click',this.setSendMethod,this);
		var sDiv=$C('div',{'class':'chat_option_list'},method_1,method_2);
		document.body.appendChild(sDiv);
		return sDiv;
	},
	setSendMethod:function(e){
		var div=e.target||e.srcElement;
		this.sMethod=div.val;
		reSetList(this.sMethodDiv,div);
		addClass(this.sMethodDiv,'hide');
	}
};
function getChat(){
	this.url='chat.php';//防止缓存
}
getChat.prototype={
	chatObj:[],//所有的
	goOn:true,
	init:function(){
		this.xmlRequest=null;//首先释放掉上一次的xmlHttpRequest对象.
		if(false==this.goOn)	return;
		this.xmlRequest=new XMLHttpRequest();//再新建一个xmlHttpRequest对象,IE下不能继续使用
		this.xmlRequest.onreadystatechange=this.checkStatus.bind(this);
		this.get();
	},
	get:function(){
		this.xmlRequest.open('GET',this.url+(this.url.indexOf('?')>0?'&':'?')+'r='+Math.random(),true);
		this.xmlRequest.send(null);
	},
	checkStatus:function(){
		if(4==this.xmlRequest.readyState){
			try{
				var re=parseJson(this.xmlRequest.responseText);
			}catch(e){
				var re='';
			}
			if('object'==typeof(re)){
				this.assignMsg(re);
				this.init();
			}else{
				setTimeout(this.init.bind(this),5000);
			}
		}
	},
	removeObj:function(obj){
		for(var i=this.chatObj.length-1;i>=0;i--){
			if(this.chatObj[i]==obj){
				this.chatObj.splice(i,1);//把这个obj从chatObj[]里移出
				if(0==this.chatObj.length)	this.goOn=false;//如果已经没有chatObj 则停止get
			}
		}
	},
	assignMsg:function(msgObj){
		var isFound,chatTo;
		for(var i=0,l=msgObj.length;i<l;i++){
			chatTo=msgObj[i].reqUser;
			isFound=false;
			for(var m=this.chatObj.length-1;m>=0;m--){
				if(this.chatObj[m].chatTo==chatTo){
					isFound=true;
					this.chatObj[m].appendChat(parseJson(msgObj[i]['message']),'him',1,msgObj[i]['timeStamp']);//parseJson(msgObj[i]['msg'])聊天信息的json对象,'him'表示收到的信息,1表示显示发消息的用户名,msgObj[i]['timestr']表示时间串
					break;
				}
			}
			if(false==isFound)	this.showNewMsg(msgObj[i]);//如果这条消息没有找到聊天窗口,则通知有新聊天对象	
		}
		msgObj=null;
	},
	showNewMsg:function(){
		debug('new message');
	}
};
function reSetList(listObj,sObj){
	var divs=listObj.getElementsByTagName('div');
	for(var i=0;i<divs.length;i++){
		divs[i].className='item';
	}
	sObj.className='item item_sele';
}
function setStyle(chatObj){
	this.chatObj=chatObj;
	chatObj=null;
}
setStyle.prototype={//设置样式
	fontDiv:false,
	fontList:false,
	sizeList:false,
	colorDiv:false,
	init:function(){
		var ficon=makeIcon('font','字体');
		eve.observe(ficon,'click',this.setFont,this);
		return ficon;
	},
	die:function(){
		if(false!=this.fontList)	removeDom(this.fontList);
		if(false!=this.sizeList)	removeDom(this.sizeList);
		if(false!=this.colorDiv)	removeDom(this.colorDiv);
		this.chatObj=null;
	},
	setFont:function(e){
		var obj=e.srcElement||e.target;
		if(false==this.fontDiv)	this.fontDiv=this.createFontDiv();
		panelSwitch(obj,this.fontDiv);
	},
	showFontList:function(e){
		var l=e.srcElement||e.target;
		if(false==this.fontList)	this.fontList=this.createFontList();
		removeClass(this.fontList,'hide');
		var p=getPosition(l);
		this.fontList.style.left=p[1]+'px';
		this.fontList.style.top=p[0]+l.offsetHeight+'px';
		this.fontList.style.zIndex=bluebirdWindow.prototype.zindex;
		if(false==this.chatObj.isList||this.chatObj.currentList!=this.fontList)	setTimeout(function(){this.chatObj.isList=true;this.chatObj.currentList=this.fontList}.bind(this),200);
		
	},
	changeFont:function(e){
		var f=e.srcElement||e.target;
		//this.chatObj.editframe.document.body.style.fontFamily=f.innerHTML;
		this.chatObj.content.style.fontFamily=f.innerHTML;
		this.chatObj.userStyle['fontFamily']=f.innerHTML;
		reSetList(this.fontList,f);
	},
	createFontList:function(){
		var fonts=['宋体','黑体','楷体_GB2312','隶书','Arial','Impact','Courier New'];
		var ldiv=$C('div',{'class':'chat_option_list chat_fontlist'});
		for(var i=0;i<fonts.length;i++){
			var t=$C('div',{'class':'item'},fonts[i]);
			t.style.fontFamily=fonts[i];
			eve.observe(t,'click',this.changeFont,this);
			switchEffect(t,'item_over');
			ldiv.appendChild(t);
		}
		addClass(ldiv.firstChild,'item_sele');
		document.body.appendChild(ldiv);
		return ldiv;
	},
	showSizeList:function(e){
		var s=e.srcElement||e.target;
		if(false==this.sizeList)	this.sizeList=this.createSizeList();
		removeClass(this.sizeList,'hide');
		var p=getPosition(s);
		this.sizeList.style.left=p[1]+'px';
		this.sizeList.style.top=p[0]+s.offsetHeight+'px';
		this.sizeList.style.zIndex=bluebirdWindow.prototype.zindex;
		if(false==this.chatObj.isList||this.chatObj.currentList!=this.sizeList)	setTimeout(function(){this.chatObj.isList=true;this.chatObj.currentList=this.sizeList}.bind(this),200);
	},
	createSizeList:function(){
		var sizes=['12px','14px','16px','18px','20px','22px','24px'];
		var ldiv=$C('div',{'class':'chat_option_list chat_sizelist'});
		for(var i=0;i<sizes.length;i++){
			var t=$C('div',{'class':'item'},sizes[i]);
			t.style.fontSize=sizes[i];
			eve.observe(t,'click',this.changeSize,this);
			switchEffect(t,'item_over');
			ldiv.appendChild(t);
		}
		addClass(ldiv.firstChild,'item_sele');
		document.body.appendChild(ldiv);
		return ldiv;
	},
	changeSize:function(e){
		var s=e.srcElement||e.target;
//		this.chatObj.editframe.document.body.style.fontSize=s.innerHTML;
		this.chatObj.content.style.fontSize=s.innerHTML;
		this.chatObj.userStyle['fontSize']=s.innerHTML;
		reSetList(this.sizeList,s);
	},
	changeStyle:function(e){
		var b=e.srcElement||e.target;
		if(/font_sele/.test(b.className)){
//			this.chatObj.editframe.document.body.style[b.sname]=b.nsname;
			this.chatObj.content.style[b.sname]=b.nsname;
			this.chatObj.userStyle[b.sname]=b.nsname;
			removeClass(b,'font_sele');
		}else{
//			this.chatObj.editframe.document.body.style[b.sname]=b.className;
			this.chatObj.content.style[b.sname]=b.className;
			this.chatObj.userStyle[b.sname]=b.className;
			addClass(b,'font_sele');
		}
	},
	showColorDiv:function(e){
		var c=e.srcElement||e.target;
		if(false==this.colorDiv)	this.colorDiv=this.createColorDiv();
		removeClass(this.colorDiv,'hide');
		var p=getPosition(c);
		this.colorDiv.style.left=p[1]+'px';
		this.colorDiv.style.top=p[0]+c.offsetHeight+'px';
		this.colorDiv.style.zIndex=bluebirdWindow.prototype.zindex;
		if(false==this.chatObj.isList||this.chatObj.currentList!=this.colorDiv)	setTimeout(function(){this.chatObj.isList=true;this.chatObj.currentList=this.colorDiv}.bind(this),200);
	},
	changeColor:function(e){
		var c=e.srcElement||e.target;
//		this.chatObj.editframe.document.body.style.color=c.style.backgroundColor;
		this.chatObj.content.style.color=c.style.backgroundColor;
		this.chatObj.userStyle['color']=c.style.backgroundColor;
		var divs=this.colorDiv.getElementsByTagName('div');
		for(var i=0;i<divs.length;i++){
			if('sele'==divs[i].className){
				divs[i].className='';
				break;
			}
		}
		c.className='sele';
	},
	createColorDiv:function(){
		var colors=['000000','993300','333300','003300','003366','333399','333333','800000','FF6600','808000','808080','008080','FF0000','FF9900','99CC00','800080','00FF00','FF00FF','FFCC00','FFFF00','00CCFF','FF99CC','CCFFCC','FB015F'];
		var cdiv=$C('div',{'class':'chat_colordiv'});
		for(var i=0;i<colors.length;i++){
			var t=$C('div',{},'&nbsp;');
			//if(i==0)	t.className='sele'; //默认
			t.style.backgroundColor='#'+colors[i];
			eve.observe(t,'click',this.changeColor,this);
			cdiv.appendChild(t);
		}
		cdiv.firstChild.className='sele'; //默认
		document.body.appendChild(cdiv);
		return cdiv;
	},
	createFontDiv:function(){
		var div=$C('div',{});
		var fontd=$C('div',{'class':'list'},'字 体');
		var sized=$C('div',{'class':'list'},'字 号');
		var boldd=$C('div',{'class':'bold'});
		boldd.sname='fontWeight';
		boldd.nsname='normal';
		var italicd=$C('div',{'class':'italic'});
		italicd.sname='fontStyle';
		italicd.nsname='normal';
		var underlined=$C('div',{'class':'underline'});
		underlined.sname='textDecoration';
		underlined.nsname='none';
		var colord=$C('div',{},'<img src="images/chat/color.gif">');
		eve.observe(fontd,'click',this.showFontList,this);
		eve.observe(sized,'click',this.showSizeList,this);
		eve.observe(boldd,'click',this.changeStyle,this);
		eve.observe(italicd,'click',this.changeStyle,this);
		eve.observe(underlined,'click',this.changeStyle,this);
		eve.observe(colord,'click',this.showColorDiv,this);
		div.appendChild(fontd);
		div.appendChild(sized);
		div.appendChild(boldd);
		div.appendChild(italicd);
		div.appendChild(underlined);
		div.appendChild(colord);
		var bNode=getElementsByClass(this.chatObj.chatWindow,'div','iconbar')[0];
		var fontDiv=$C('div',{'class':'fontdiv'},div,$C('div',{'class':'clear'}));
		this.chatObj.chatWindow.insertBefore(fontDiv,bNode);
		return fontDiv;
	}
};
function addEmote(chatObj){
	this.chatObj=chatObj;
	chatObj=null;
}
addEmote.prototype={
	emoteDiv:false,
	init:function(){
		var eicon=makeIcon('emote','表情');
		eve.observe(eicon,'click',this.showemoteDiv,this);
		return eicon;
	},
	showemoteDiv:function(e){
		var obj=e.srcElement||e.target;
		if(false==this.emoteDiv)	this.emoteDiv=this.createEmoteDiv();
		//panelSwitch(obj,this.emoteDiv);
		//if(false==obj.isOpen)	return;
		removeClass(this.emoteDiv,'hide');
		var p=getPosition(obj);
		this.emoteDiv.style.left=p[1]+'px';
		this.emoteDiv.style.top=p[0]-this.emoteDiv.offsetHeight+'px';
		this.emoteDiv.style.zIndex=bluebirdWindow.prototype.zindex;
		if(false==this.chatObj.isList||this.chatObj.currentList!=this.emoteDiv)	setTimeout(function(){this.chatObj.isList=true;this.chatObj.currentList=this.emoteDiv}.bind(this),200);
	},
	createEmoteDiv:function(){
		var ediv=$C('div',{'class':'chat_emotion'});
		for(var i=0;i<24;i++){
			var m=$C('img',{'src':'images/chat/emotion/'+i+'_s.gif'});
			var e=$C('div',{},m);
			switchEffect(e,'over');
			eve.observe(m,'click',this.insertEmote,this);
			ediv.appendChild(e);
		}
		document.body.appendChild(ediv);
		return ediv;
	},
	insertEmote:function(e){
		var em=e.srcElement||e.target;
		var src=em.src.replace('_s','');
		/*if(browser.ie){
			var span=$C('span',{},$C('img',{'src':src}));
			span.contentEditable="false";
			this.chatObj.content.appendChild(span);
		}else{*/
			src=src.split('/');
			this.chatObj.content.value+='[emote='+src[src.length-1]+']';
		//}
		//this.chatObj.editframe.focus();
		//this.chatObj.content.execCommand('InsertImage',false,);
		//this.chatObj.content.style.backgroundImage='url(','_b')+')';
		//for(m in this.chatObj.content.style)	debug(m);
	},
	die:function(){
		if(false==this.emoteDiv)	return;
		removeDom(this.emoteDiv);
		this.chatObj=null;
	}
};
function useShort(chatObj){
	this.chatObj=chatObj;
	chatObj=null;
}
useShort.prototype={
	shortDiv:false,
	init:function(){
		var aicon=makeIcon('short','常用');
		eve.observe(aicon,'click',this.showShortDiv,this);
		return aicon;
	},
	showShortDiv:function(e){
		var obj=e.srcElement||e.target;
		if(false==this.shortDiv)	this.shortDiv=this.createShortDiv();
		removeClass(this.shortDiv,'hide');
		var p=getPosition(obj);
		this.shortDiv.style.left=p[1]+'px';
		this.shortDiv.style.top=p[0]+obj.offsetHeight+'px';
		this.shortDiv.style.zIndex=bluebirdWindow.prototype.zindex;
		if(false==this.chatObj.isList||this.chatObj.currentList!=this.shortDiv)	setTimeout(function(){this.chatObj.isList=true;this.chatObj.currentList=this.shortDiv}.bind(this),200);
		//eve.stopObserve(obj,'click',this.showShortDiv);
//		obj.onclick=function(){alert(1);};

	},
	createShortDiv:function(){
		shorts=['你好','哦','好的','再见','我知道了.'];
		var sdiv=$C('div',{'class':'chat_option_list chat_shortdiv'});
		for(var i=0;i<shorts.length;i++){
			var s=$C('div',{'class':'item'},shorts[i]);
			switchEffect(s,'item_over');
			sdiv.appendChild(s);
		}
		document.body.appendChild(sdiv);
		return sdiv;
	},
	die:function(){
		if(false==this.shortDiv)	return;
		removeDom(this.shortDiv);
		this.chatObj=null;
	}
};
function showHelp(chatObj){
	this.chatObj=chatObj;
	chatObj=null;
}
showHelp.prototype={
	init:function(){
		var sicon=makeIcon('help','帮助');
		return sicon;
	},
	die:function(){return;}
};
function panelSwitch(obj,panel){
	if(true==obj.isOpen){
		addClass(panel,'hide');
		obj.isOpen=false;
		removeClass(obj,'icon_sel');
	}else{
		removeClass(panel,'hide');
		obj.isOpen=true;
		addClass(obj,'icon_sel');
	}
}
function makeIcon(cname,intro){
	var s=$C('div',{'class':cname},intro);
	switchEffect(s,'icon_over');
	return s;
}
var bluebirdhszCookie={
	set:function(name,value,options){
		options=options||{};
		if (value===null){
			value='';
			options.expires=-1;
        }
		var expires='';
		if(options.expires){
			var date;
			date=new Date();
			date.setTime(date.getTime()+(options.expires*24*60*60*1000));
			expires=';expires='+date.toUTCString();
		}
		var path=options.path?';path='+(options.path):'';
		var domain=options.domain?';domain='+(options.domain):'';
		var secure=options.secure?':secure':'';
		document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');
	},
	get:function(name){
		var cookieValue=null;
		if(document.cookie&&document.cookie!=''){
			var cookies=document.cookie.split(';');
			for(var i=0,l=cookies.length;i<l;i++){
				var cookie=cookies[i];
				if(cookie.substring(0,name.length+1)==(name+'=')){
					cookieValue=decodeURIComponent(cookie.substring(name.length+1));
					break;
				}
			}
		}
		return cookieValue;
	}
};
function encodeHtml(str){
	return str;
}
function decodeHtml(str){
	str=str.replace(/</g,'&lt;');
	str=str.replace(/>/g,'&gt;');
	str=str.replace(/"/g,'&quot;');
	if(/\[emote=\d+\.gif\]/.test(str))	str=str.replace(/\[emote=(\d+\.gif)\]/g,'<img src="images/chat/emotion/$1"/>');
	str=str.replace(/\r?\n/g,'<br/>');
	return str;
}
JS_FILES.push('chat');